package com.springbootbase.springbootproject.controller;


import com.springbootbase.springbootproject.pojo.*;
import com.springbootbase.springbootproject.service.recommendationService;
import org.apache.tika.exception.TikaException;
import org.mybatis.logging.Logger;
import org.mybatis.logging.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;

//推荐偏重
@RestController
@RequestMapping("/overWeight")
public class recommendationController {
    @Autowired
    private recommendationService recommendationService;
    private static final Logger logger = LoggerFactory.getLogger(recommendationController.class);

    @GetMapping("/getRecommendSet")
    public Result<Recommendation> getRecommendSet(Long id){
       Recommendation recommendation = recommendationService.getRecommendSet(id);
        return Result.success(recommendation);
    }
    @PostMapping("/updateRecommendSet")
    public Result updateSet(@RequestBody @Validated Recommendation recommendation){
        recommendationService.updateSet(recommendation);
        return Result.success();
    }

    @GetMapping("/getRecommendList")
    public Result getRecommendList(Long id,int pageSize,int pageNum){
        ListResponse listResponse  = recommendationService.getRecommendList(id,pageSize,pageNum);
        return Result.success(listResponse);
    }

    @GetMapping("/getRecommend")
    public Result getRecommend(Long id,String userType,double departmentSet, double searchWaySet, double hobbySet ) throws TikaException, IOException {
        if (userType.equals("student")){
            List<List> teacherList = recommendationService.getRecommendForStudent(id,userType,departmentSet,searchWaySet,hobbySet);
            return Result.success(teacherList);
        }else{
            List<List> studentList = recommendationService.getRecommendForTeacher(id,userType,departmentSet,searchWaySet,hobbySet);
            return Result.success(studentList);
        }
    }


}
